package mysql.types;

import utils.titles.Title;

/**
 * Created by thormentor on 27-04-2014.
 */
public class Type {
    private final Class<?> type;
    private final String[] patterns;

    protected Type(Class<?> type, String... patterns) {
        this.type = type;
        this.patterns = patterns;
        Types.TYPES.add(this);
    }

    public Class<?> getType() {
        return type;
    }

    public String[] getPatterns() {
        return patterns;
    }

    public boolean match(String temp) {
        for (String pattern : patterns)
            if (temp.matches(pattern))
                return true;

        return false;
    }

    @Override
    public String toString() {
        return Title.fromObject(this).toUpperUnderscore();
    }
}
